 var id = getvl("id");
 var rudsid=getvl("rudsid"); 
 var darss='';
	$(function(){
		      if(id != ''&&rudsid!='') {
		      	zhuji();
		 $("#slideBox").html("");
		 $("#shangpingxiangqing").html("");
		 $("#jiarujinghuoche").attr("href","7.4.0goods_guige.html?id="+id);
		$.ajax({
        url: urlcore + "/api/goods/particulars2?id="+id,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					//alert(JSON.stringify(data.data.goods))
					  $('#img_details').html("");
				    var da=data.data;
				 var shangpingxiangqing="";
				      if(da.goods.goods_simple!=null && da.goods.goods_simple!=""){
				          shangpingxiangqing+='<center>描述</center>';
				           shangpingxiangqing+=da.goods.goods_simple;
				        }
				      if(da.list!=null && da.list!=""){
				      	var svu=0;
				      	  shangpingxiangqing+='<center>参数</center>';
				      	   $.each(da.list, function(s,n) {
				       shangpingxiangqing+="颜色 :"+n.colour.colourName;
				        shangpingxiangqing+="尺寸 :"+n.size.sizeName;
				        svu++;
				              if(da.list.length==svu){
				              	     	 $.each(da.propertyList, function(y,q) {
				         	
				         shangpingxiangqing+=q.oneProperty+":"+q.twoProperty;
                          });
				              }
				    
				      	   });
				        }
				    $("#shangpingxiangqing").append(shangpingxiangqing);
				    
				    //分类按钮
				$("#fenlei").attr("href","6.2.0dianpu_fenlei.html?id="+da.shopinfo.id);
				       var headImg=da.goods.goods_url;
	     var imgStr1='<div id="slideBox" class="slideBox">'+
		      '<div class="bd" id="lunbo">'+
			'<ul>';
			var imgsss='<div><img onerror="errorImg(this)" style="height: 180%;width: 100%;" src="'+da.goods.cover_url+'"></div><br>';
			 imgStr1 +='<li><img  onerror="errorImg(this)" style="height: 180%;width: 100%;" src="'+da.goods.cover_url+'" data-preview-src="" data-preview-group="1" /></li>';
					 if(headImg != null && headImg != '') {
						var imgarr1 = headImg.split("***");
						$.each(imgarr1, function(index, value) {
						 imgStr1 +='<li><img onerror="errorImg(this)" data-preview-src="" data-preview-group="1" style="height: 180%;width: 100%;" src="'+value+'" /></li>';
					 imgsss+='<div><img onerror="errorImg(this)" style="height: 180%;width: 100%;" src="'+value+'"></div><br>';
						});
					}
					 imgStr1 +='</ul>'+
'		</div>'+
'		<div class="hd">'+
'			<ul></ul>'+
'		</div>'+
'	</div>';
	$("#imgsss").append(imgsss);
						$("#lunbotu").append(imgStr1);
										$(function(){
							TouchSlide({
		slideCell:"#slideBox",
		titCell:".hd ul", //开启自动分页 autoPage:true ，此时设置 titCell 为导航元素包裹层
		mainCell:".bd ul", 
		effect:"leftLoop", 
		autoPage:true,//自动分页
		autoPlay:true //自动播放
	});
						}); 
					
		var datetime=new Date(da.goods.upt_datetime).pattern("yyyy/MM/dd hh:mm:ss");
		var xianshi=new  Date(da.goods.upt_datetime).pattern("MM/dd hh:mm");
		var zuotian=new  Date(da.goods.upt_datetime).pattern("hh:mm");
                var d1 = new Date(); 
  var d2 = new Date(Date.parse(datetime));

  var dateds;
             if(parseInt((d1 - d2) / 60000)<60){
             	   dateds=parseInt((d1 - d2) / 60000)+"分钟前更新";
             }else{
             if(parseInt((d1 - d2) / 60000)<2880){
             	     if(parseInt((d1 - d2) / 60000)<1440){
             	     	if(parseInt(parseInt((d1 - d2) / 60000)/60)<24){
             	      dateds=parseInt(parseInt((d1 - d2) / 60000)/60)+"小时前更新";
             	     	}else{
             	     		dateds=parseInt(parseInt((d1 - d2) / 60000)/60)+"小时前更新";
             	     	}
             	     }else{
             	     	dateds="昨天"+zuotian+"更新";
             	     }
             }else{
             	dateds=xianshi+"更新";
             }
              }
  
  var jianjie='<h2>'+da.goods.goods_title+'</h2>'+
	'<ul class="clearfix">'+
		'<li>'+
			'<em>'+dateds+'</em>'+
		'</li>'+
		'<li>'+
			'<em>'+da.goods.look_time+'次浏览</em>'+
		'</li>'+
		'<li>'+
			'<em>已卖出'+da.goods.sale_num+'件</em>'+
		'</li>'+
	'</ul>';
	       $("#jianjie").append(jianjie);  //产品规格信息完结

          
          var dikou='<ul>';
          if(da.shopinfo.openGold==1){
           dikou+='<li><img src="images/di.png" />可用金币抵扣'+da.shopinfo.allGoldRate+'%</li>';
          }else{
          	 dikou+='<li><img src="images/di.png" />不参与金币抵扣活动</li>';
          }
		
		dikou+='<li>';
		  if(da.goods.gold_rate<=0){
		  	dikou+='<img src="images/zeng.png" />不赠送金币';
		  }else{
		  	dikou+='<img src="images/zeng.png" />每件赠送'+da.goods.gold_rate+'个金币';
		  }
		dikou+='</li>'+
		'<li><img src="images/pi.png" />全店满'+da.shopinfo.mixNumber+'件可混批采购</li>'+
	    '</ul>';
           $("#dikou").append(dikou);  //抵扣优惠完结
  
           var pingjia='<div class="Pingjia_title">'+
		'<a href="7.1.0goods_pingjia.html?id='+da.goods.id+'">'+da.commentList.length+'条评价</a>'+
	'</div>';
	         $.each(da.commentList,function(m,z){
	         	 var dar=new Date(z.gmt_datetime).pattern("yyyy-MM-dd hh:mm");
	    pingjia+='<div class="sell_pingjia_xinxi">'+
		'<div class="sell_pingjia_tu">'+
			'<img src="'+z.head_img+'" />'+
		'</div>'+
		'<div class="sell_pingjia_wenzi">'+
			'<div class="sell_pingjia_mz clearfix">'+
				'<h5>'+z.user_name+'</h5>'+
				'<div class="fr">';
				       for(var i=0;i<z.service_level;i++){
				       	pingjia+='<img src="images/star.png" />';
				       }
					pingjia+='<i>4.0分</i>'+
				'</div>'+
			'</div>'+
			'<span>'+dar+'</span>'+
			'<p>'+z.comment_content+'</p>'+
		'</div>'+
	'</div>';
	             return false;
	         });
	
                   $("#pingjia").append(pingjia);  //评价完结
                   var dianpu=
                   '<dl>'+
		'<a href="6.0.0dianpu.html?id='+da.shopinfo.id+'">'+
			'<dt>'+
				'<img  onerror="errorImg(this)" src="'+da.shopinfo.headImg+'" />'+
			'</dt>'+
			'<dd>'+
				'<h5>'+da.shopinfo.storeName+'</h5>'+
				'<h6>全部商品共'+da.size+'件</h6>'+
				'<span>'+da.shopinfo.province+da.shopinfo.city+da.shopinfo.county+'</span>'+
			'</dd>'+
		'</a>'+
	'</dl>'+
	'<div class="Dianpu_quanbu">'+
		'<a href="6.0.0dianpu.html?id='+da.shopinfo.id+'">全部商品<span>('+da.size+')</span></a>'+
		'<a href="tel:'+da.shopinfo.phone+';">联系店家</a>'+
	'</div>';
	      $('#dianpu').append(dianpu);   //店铺信息
	      shifoushouchang();
                   //商品详情图片还没添加 轮播图还没做
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}
			},
			error: function() {
				alert("error");
			}
		});
		
		
	
		$.ajax({
        url: urlcore + "/api/rushGoods/selectOne?id="+rudsid,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					var das=data.data;
					if(das!=null){
					$(".shijian").val(das.rushTime);
						
						/*$(".shijian").val(dar);
						alert(dar);*/
						sessionStorage.setItem("youhuijia",das.cheapPrice);
		var qianggoujiage='<div class="fl price_left clearfix">'+
'		<h5>&yen;<span>'+das.cheapPrice+'</span></h5>'+
'		<h6>&yen;'+das.goods.packPrice+'</h6>'+
'	</div>';

$("#shengyujianshu").html("剩余件数"+(das.rushAmount-das.surplusstock)+"%")
             $("#qianggoujiage").append(qianggoujiage);
					}
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});
		
         }else{
         	
            alert("请传入商品id");	
         }
	
  });



/*					
var userid="";
chaxunwodezhuji();
function chaxunwodezhuji(){
		$.ajax({
		url: urlcore + "/api/user/getadmin",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
			chaxunwodezhuji2(data.data.id);
			userid=data.data.id;
			}
		},
		error:function() {
			/* Act on the event 
			alert("error");
		}
	});	
	
}*/
var currentPage=1;

function chaxunwodezhuji2(){
	
	$(document).ready(function() {
		init(currentPage);
	});
	function init(pageNo) {
		
	       if(uuuuid!=""){
	       	
		$.ajax({
		url: urlcore + "/api/myFoot/selectPage2?current="+pageNo+"&userId="+uuuuid,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				var wodezhuji="";
				$.each(data.data.list, function(y,w) {
					wodezhuji+='<dl>'+
'		<dt>'+
'			<img onerror="errorImg(this)" src="'+w.goods.coverUrl+'"/>'+
'		</dt>'+
'		<dd>'+
'			<h5>'+w.goods.goodsTitle+'</h5>'+
'			<h6>&yen;'+w.goods.tradePrice+'- &yen;'+w.goods.packPrice+'</h6>'+
'		</dd>'+
'	</dl>'+
'	'+
'	<dl>';
					});
			   $("#wodezhuji").append(wodezhuji);
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	
	}else{
		//alert("未登录");
	}
	}
	PageClick = function(pageclickednumber) {
		init(pageclickednumber);
	}
}






function shouchang(){
	if(uuuuid!=''){
	
	var imgs=$("#shifoushouchangs").attr("src");
	
	if(imgs=="images/detail_bottom04.png"){
		
      $("#shifoushouchangs").attr("src","images/detail_bottom04.png");
         $.ajax({
		url: urlcore + "/api/myCollection/update", 
		type: "post",
		contentType: "application/json;charset=utf-8",
		data: JSON.stringify({
			userId:uuuuid,
			goodsId:id,
			status:2
		}),
		dataType: "json",
		success: function(data) {
			if(data.success == true) {
				slelectnot();
			} else if(data.code == 'OVERTIME') {
				var thisUrl = window.location.href;
				if(thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href = "login.html";
				}
			} else {
				alert(data.msg);
			}
		},
		error: function() {
			alert("error");
		}
	});
	
      
      
	}else if(imgs=="images/detail_bottom05.png"){
		  $("#shifoushouchangs").attr("src","images/detail_bottom05.png");
         $.ajax({
		url: urlcore + "/api/myCollection/update", //userid
		type: "post",
		contentType: "application/json;charset=utf-8",
		data: JSON.stringify({
			userId:uuuuid,
			goodsId:id,
			status:1
		}),
		dataType: "json",
		success: function(data) {
			if(data.success == true) {
				  
			} else if(data.code == 'OVERTIME') {
				var thisUrl = window.location.href;
				if(thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href = "login.html";
				}
			} else {
				alert(data.msg);
			}
		},
		error: function() {
			alert("error");
		}
	});
	}else{
		  $("#shifoushouchangs").attr("src","images/detail_bottom04.png");
	}
	}
}



function shifoushouchang(){
	      if(uuuuid!=""){
		$.ajax({
		url: urlcore + "/api/goods/isCollection2?id="+id+"&userId="+uuuuid,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			
			if(data.success == true) {
				 var da=data.data;
				
				 
				    if(da==null){
				   $("#shifoushouchangs").attr("src","images/detail_bottom04.png");
				    }else{
				    	if(da.status==1){
			 	 $("#shifoushouchangs").attr("src","images/detail_bottom05.png");
			 }else{
			 	$("#shifoushouchangs").attr("src","images/detail_bottom04.png");
			 }
				    }
				 
			}else{
				
				 
				$("#shifoushouchangs").attr("src","images/detail_bottom04.png");
			}
			
			
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	
	 }
}



function zhuji(){
	 if(uuuuid!=""){
	 	    $.ajax({  
        url : urlcore + "/api/myFoot/add2",
        type : "post",  
        contentType: "application/json;charset=utf-8",
        data : JSON.stringify({
        "userId":uuuuid,	
        "goodsId":id,
        }),
        dataType: "json",
        success: function(data) {//data是返回的hash,key之类的值，key是定义的文件名 
        	if(data.success == true) {
        	}else{
        	//	alert(data.msg);
        	}
        },
        error:function(){  
            alert("修改失败");  
        }  
    });     
	 }else{
	 	//alert("未登录");
	 }
}